package kr.co.doriclassic.powerjava.chapter11;

class AA{
	int a;

	//반드시 오버라이딩 해야함
	@Override
	public boolean equals(Object obj) {
		if(obj instanceof AA){//같다면
			return a==((AA)obj).a;
		}	
		return false;
	}
	
}
public class EqualsEx {
	public static void main(String[] args) {
		AA a1 = new AA();
		AA a2 = new AA();
		
		a1.a=1;
		a2.a=2;
		System.out.println(a1.equals(a2)?"같다":"다르다");
	}
}
